// $Id: TransitionShape.cs 124 2007-05-28 15:51:51Z xavex2k $
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Diagram.View;

namespace PetriDiagram.Shapes
{
    [Serializable]
    public class TransitionShape : NetElementShape
    {
        private Size size;

        public TransitionShape()
        {
            size = new Size( 10, 30 );
            Bounds = Rectangle.Empty;
            Cursor = new Cursor( new MemoryStream( Resource.TransitionCursor ) );
        }

        public override Shape Clone()
        {
            return new TransitionShape();
        }

        public override void Draw( Graphics g )
        {
            if( Transition.IsActive )
                g.FillRectangle( Brushes.Green, Bounds );
            else
                g.FillRectangle( Brushes.Black, Bounds );

            base.Draw( g );
        }

        private Transition Transition { get { return Entity as Transition; } }

        public override Size MinSize
        {
            get
            {
                return size;
            }
        }

        public override Diagram.Handles.Anchor CreateConnectionHandle()
        {
            return new PetriNetElementAnchor( this );
        }
    }
}
